home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
Main.bin
/
JARArchiver.java
< prev
next >
Wrap
Text File
|
1998-11-03
|
3KB
|
134 lines
package com.symantec.itools.tools.archive;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import com.symantec.itools.lang.Classpath;
import com.symantec.itools.lang.NotJavaNameException;
import com.symantec.itools.io.FileSystem;
import com.symantec.itools.lang.Debug;
import com.symantec.itools.lang.ProcessManager;
/**
* @author Symantec Internet Tools Division
* @version 1.0
* @since VCafe 3.0
*/
public class JARArchiver
extends TypeArchiver
{
/**
* @since VCafe 3.0
*/
protected ProcessManager processManager;
public JARArchiver(Options options)
{
super(options);
}
/**
* @param errorMsg TODO
* @since VCafe 3.0
*/
public boolean create(StringBuffer errorMsg)
{
if(options.isSigning())
{
if(options.getSigner().equals("netscape"))
{
return (createUsingNetscapeJAR(errorMsg));
}
}
return (createUsingSunJAR(errorMsg));
}
/**
* @param errorMsg TODO
* @since VCafe 3.0
*/
protected boolean createUsingNetscapeJAR(StringBuffer errorMsg)
{
DirectoryArchiver archiver;
String outFile;
StringBuffer command;
outFile = options.getOutputLocation();
options.setOutputLocation(options.getTempDir());
archiver = new DirectoryArchiver(options);
if(!(archiver.create(errorMsg)))
{
return (false);
}
options.setOutputLocation(outFile);
return (true);
}
/**
* @param errorMsg TODO
* @since VCafe 3.0
* @deprecated
*/
protected boolean createUsingSunJAR(StringBuffer errorMsg)
{
DirectoryArchiver archiver;
String outFile;
StringBuffer command;
String tempDir;
outFile = options.getOutputLocation();
tempDir = options.getTempDir();
options.setOutputLocation(tempDir);
archiver = new DirectoryArchiver(options);
if(!(archiver.create(errorMsg)))
{
return (false);
}
options.setOutputLocation(outFile);
command = new StringBuffer(FileSystem.quoteIfNeeded(FileSystem.getCanonicalPath(options.getSunTools(), true) + "jar.exe"));
command.append(' ').append(options.getArchiverArgs());
try
{
processManager = new ProcessManager();
if(processManager.monitorLaunchedProcess(Runtime.getRuntime().exec(command.toString())) != 0)
{
errorMsg.append("Failed to create " + options.getOutputLocation());
return (false);
}
}
catch(IOException ex)
{
errorMsg.append("Failed to run " + FileSystem.getCanonicalPath(options.getSunTools(), true)).append("jar.exe");
Debug.logException(ex);
return (false);
}
return (true);
}
/**
* @since VCafe 3.0
*/
public void cancel()
{
if(processManager != null)
{
processManager.destroyProcess();
processManager = null;
}
}
}